package com.wine.exam.domain;

import java.io.Serializable;
import java.util.Date;

import com.baomidou.mybatisplus.annotation.*;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.*;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.wine.common.annotation.Excel;
import com.wine.common.core.domain.BaseEntity;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 试卷对象 exam_paper
 *
 * @author wine
 * @date 2022-10-13
 */
@Getter
@Setter
@EqualsAndHashCode
@AllArgsConstructor
@NoArgsConstructor
@ToString
@TableName("exam_paper")
public class Paper  implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 关联查询所需
     */
    @TableField(exist = false,select = false)
    private Subject subject;

    /**
     * 关联查询所需
     */
    @TableField(exist = false,select = false)
    private String[] questionIds;

    /**
     * 关联查询所需
     */
    @TableField(exist = false,select = false)
    private Boolean isRandomQuestion;
    /**
     * 试卷表主键
     */
    @JsonSerialize(using = ToStringSerializer.class)
    @TableId(value = "paper_id", type = IdType.AUTO)
    private Long paperId;

    /**
     * 排序
     */
    @Excel(name = "排序")
    @TableField(value = "order_num")
    private Long orderNum;

    /**
     * 试卷名称
     */
    @Excel(name = "试卷名称")
    @TableField(value = "paper_name")
    @Length(min = 1, max = 50, message = "试卷名称长度在{min}到{max}个之间")
    private String paperName;

    /**
     * 学科id
     */
    @Excel(name = "学科id")
    @TableField(value = "subject_id")
    private Long subjectId;

    /**
     * 试卷类型( 1.固定试卷 4.时段试卷 6.任务试卷 )
     */
    @Excel(name = "试卷类型( 1.固定试卷 2.时段试卷 3.任务试卷 )")
    @Pattern(regexp = "[1,2,3]", message = "试卷类型( 1.固定试卷 2.时段试卷 3.任务试卷 )")
    @TableField(value = "paper_type")
    @JsonSerialize(using = ToStringSerializer.class)
//    暂定都是时段试卷，前端发送请求写死。这里不修改
    private Long paperType;

    /**
     * 年级
     */
  /*  @Excel(name = "年级")
    private Long gradeLevel;*/

    /**
     * 试卷总分(千分制)
     */
    @Excel(name = "试卷总分")
    @TableField(value = "paper_score")
//    这里应该是后端计算得出
    /*@Max(value = 100, message = "分数不能大于{max}")
    @Min(value = 1, message = "分数不能低于{min}")*/
    private Long paperScore;

    /**
     * 题目数量
     */
    @Excel(name = "题目数量")
    //    这里应该是后端计算得出
    @TableField(value = "question_count")
    @JsonSerialize(using = ToStringSerializer.class)
    private Long questionCount;

    /**
     * 建议时长(分钟)
     */
    @Excel(name = "建议时长(分钟)")
    @TableField(value = "suggest_time")
    @NotBlank(message = "建议时长不能为空")
    private Long suggestTime;

    /**
     * 时段试卷 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "时段试卷 开始时间", width = 30, dateFormat = "yyyy-MM-dd")
    @TableField(value = "limit_start_time")
    @JsonSerialize(using = ToStringSerializer.class)
    @NotBlank(message = "开始期限不能为空")
    private Long limitStartTime;

    /**
     * 时段试卷 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "时段试卷 结束时间", width = 30, dateFormat = "yyyy-MM-dd")
    @TableField(value = "limit_end_time")
    @JsonSerialize(using = ToStringSerializer.class)
    @NotBlank(message = "结束期限不能为空")
    private Long limitEndTime;

    /**
     * 状态（0正常 1停用）
     */
    @Excel(name = "试卷状态", readConverterExp = "0=正常,1=停用")
    @TableField(value = "status")
    @Pattern(regexp = "[0,1]", message = "问题状态:0=正常,1=停用")
    private String status;

    /**
     * 删除标志（0代表存在 2代表删除）
     */
    @TableLogic
    @TableField(value = "del_flag", select = false)
    private String delFlag;


    /**
     * 创建人
     */

    @TableField(value = "create_by")
    private String createBy;

    /**
     * 创建时间
     */

    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "create_time", fill = FieldFill.INSERT)
    private Date createTime;


    /**
     * 更新人
     */

    @TableField(value = "update_by")
    private String updateBy;

    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @TableField(value = "update_time", fill = FieldFill.INSERT_UPDATE)
    private Date updateTime;

}
